<?php
// +----------------------------------------------------------------------
// | Author: yaoyihong <510974211@qq.com>
// +----------------------------------------------------------------------

namespace app\backend\controller;
use app\common\controller\AdminBase;
use \tpfcore\Core;
use app\common\controller\ControllerBase;

class UserAddress extends AdminBase
{	

	public function index(){
		if(IS_GET) return $this->fetch();
		if(IS_POST || IS_AJAX){
			$per_page = isset($this->param['per_page']) && !empty($this->param['per_page']) ? (int)$this->param['per_page'] : 10;
			$this->jump([
				0,'success',
				Core::loadModel($this->name)->getUserAddress([
					"field"=>"__USER__.username,__USER_ADDRESS__.*",
					"join"=>[
                      "join"=>["__USER__"],
                      "condition"=>["__USER__.id=__USER_ADDRESS__.user_id"],
                      "type"=>["left"]
                  	],
					'order'=>"id DESC",
					'paginate'=>['rows' => $per_page],
				])
			]);
		}
	}
	public function del(){
		if(IS_POST || IS_AJAX){
        	$this->jump(Core::loadModel($this->name)->delUserAddress($this->param));
      	}
	}
}